package org.springblade.common.enums;

import java.util.StringJoiner;

public enum ChineseUnicode {

	BASE("基本汉字","\\u4E00-\\u9FA5"),
	BASE_EXTEND("基本汉字补充","\\u9FA6-\\u9FEF"),
	EXTEND_A("扩展A","\\u3400-\\u4DB5"),
	EXTEND_B("扩展B","\\u20000-\\u2A6D6"),
	EXTEND_C("扩展C","\\u2A700-\\u2B734"),
	EXTEND_D("扩展D","\\u2B740-\\u2B81D"),
	EXTEND_E("扩展E","\\u2B820-\\u2CEA1"),
	EXTEND_F("扩展F","\\u2CEB0-\\u2EBE0"),
	KX_BS("康熙部首","\\u2F00-\\u2FD5"),
	BS_EXTEND("部首扩展","\\u2E80-\\u2EF3"),
	JR("兼容汉字","\\uF900-\\uFAD9"),
	JR_EXTEND("兼容扩展","\\u2F800-\\u2FA1D"),
	PUA_GBK("PUA(GBK)部件","\\uE815-\\uE86F"),
	BJ_EXTEND("部件扩展","\\uE400-\\uE5E8"),
	PUA_EXTEND("PUA增补","\\uE600-\\uE6CF"),
	BH("汉字笔画","\\u31C0-\\u31E3"),
	JG("汉字结构","\\u2FF0-\\u2FFB"),
	PY("汉语注音","\\u3105-\\u312F"),
	ZY_EXTEND("注音扩展","\\u31A0-\\u31BA"),
	CYCLE("〇","\\u3007");
	
	//描述
	String desc;
	String unicodeRange;
	
	
	
	private ChineseUnicode(String desc, String unicodeRange) {
		this.desc = desc;
		this.unicodeRange = unicodeRange;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public String getUnicodeRange() {
		return unicodeRange;
	}
	public void setUnicodeRange(String unicodeRange) {
		this.unicodeRange = unicodeRange;
	}
	 
	public static String getChineseRegx() {
		StringJoiner stringJoiner=new StringJoiner("|");
		for(ChineseUnicode chineseUnicode:ChineseUnicode.values()) {
			stringJoiner.add(String.format("[%s]", chineseUnicode.getUnicodeRange()));
			
		}
		return stringJoiner.toString();
	}
	
	public static boolean isChinese(String str) {
		return str.matches(getChineseRegx());
	}
	public static void main(String[] args) {
		System.out.println(getChineseRegx());
	}
	
}
